#ifndef APPLYFRIEND_H
#define APPLYFRIEND_H

#include <QDialog>
#include <QLabel>
#include <QMap>
#include <QPoint>
#include <QVector>
#include "clickedlabel.h"
#include "friendlabel.h"
#include "userdata.h"
#include <memory>
namespace Ui {
class ApplyFriend;
}

class ApplyFriend : public QDialog
{
    Q_OBJECT
private:
    Ui::ApplyFriend *ui;
    //为已选择的标签
    QVector<std::shared_ptr<FriendLabel>> _selectedLabels;
    // 可选择的标签
    QVector<std::shared_ptr<ClickedLabel>> _optionalLabels;

    QVector<QString> _tipData;
    QPoint _optionaLabelPoint;
    QPoint _selectedLabelPoint;
    std::shared_ptr<SearchInfo> _si;

public:
    explicit ApplyFriend(QWidget *parent = nullptr);
    ~ApplyFriend();
    void InitTipLbs();
    void setSearchInfo(std::shared_ptr<SearchInfo> si);
    virtual bool eventFilter(QObject *watched, QEvent *event) override;

private:
    void resetLabel();
    void addSelectedLabel(QString name);
    void addOptionalLabel(QString label);
    void removeOptionalLabel(QString label);
    void removeSelectedLabel(QString label);

public:
    // 展示所有标签
    void slot_showMoreLabel();
    // 按下回车添加标签
    void slot_labelEnter();
    // 移除标签
    void slot_removeFriendLabel(QString text);
    // 点击tiplb 增加标签
    void slot_delLabel(QString text);
    // 标签输入框内容改变，提示框内容同步变化
    void slot_labelTextChange(const QString &text);
    // 标签编辑完成，添加标签
    void slot_labelEditFinished();
    // 添加标签
    void slot_addLabelByClickTip(QString text);
    // 发送请求
    void slot_applySure();
    // 取消请求
    void slot_applyCancal();
    // 删除标签
    void slot_labelStateChange();
private slots:
    void on_sure_btn_clicked();
    void on_cancel_btn_clicked();
};

#endif // APPLYFRIEND_H
